// comment function for 3d
$.fn.getCookie = function (c_name, d_value)
{
  if (document.cookie.length>0){
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1){
      c_start=c_start + c_name.length+1;
      c_end=document.cookie.indexOf(";",c_start);
      if(c_end==-1){c_end=document.cookie.length;}
      return unescape(document.cookie.substring(c_start,c_end));
    }
  }else{
    $().setCookie(c_name,d_value);
  }
  return d_value;
};

$.fn.setCookie = function(c_name,value)
{
  var expiredays = 365;
  var exdate = new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_name+ "=" +escape(value)+
  ((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
};


// -----------------------------------------------------------------------------
// get all page div
// -----------------------------------------------------------------------------
$.fn.createDiv = function(sSrc){
    var oThis = $(this);
    var shadow = document.createElement("div");
    $("body").css({
           'margin':'0'
          ,'padding':'0'
    });
    
    shadow.setAttribute("id","speShadow");
    shadow.style.zIndex="100";

    var speCloseBar = document.createElement("div");
    speCloseBar.setAttribute("id","speCloseBar");
    speCloseBar.style.zIndex="1000";
    
    var box = document.createElement("div");
    box.setAttribute("id","speBox");
    box.style.zIndex="999";
    
    document.body.appendChild(shadow);
    document.body.appendChild(box);
    
    $("#speBox").draggable();
    $(box).load(sSrc, function(response, status, xhr) {
        if (status == "error") {
          var msg = "Sorry but there was an error: ";
          $("#error").html(msg + xhr.status + " " + xhr.statusText);
        }
    });
    
    //$("#speShadow").click(function(){ $().closeMyDiv(); });
};

// -----------------------------------------------------------------------------
// dis page div
// -----------------------------------------------------------------------------
$.fn.closeMyDiv = function(){
   $("body").css({
           'margin':''
          ,'padding':''
    });
    var box = document.getElementById("speBox");
    var shadow = document.getElementById("speShadow");
    document.body.removeChild(box);
    document.body.removeChild(shadow);
};

$.fn.closeMyDiv02 = function(){
    var box = document.getElementById("speBox");
    var shadow = document.getElementById("speShadow");
    box.style.display = "none";
    shadow.style.display = "none";
};

// -----------------------------------------------------------------------------
// change input.iptRate color when change
// -----------------------------------------------------------------------------
$.fn.chgIptClr = function(){
  $("input.iptRate").change(function(){
    $(this).css('background-color', '#FEFF91');
  });
};

// -----------------------------------------------------------------------------
// change thie number to float like N.xx
// -----------------------------------------------------------------------------
$.fn.fixstr = function(){
	return $.each($(this), function(idx,ele){
    var numv=ele.value-0;
    var sign=(numv>=0?1:-1); // Will give 1 for num=0
  	var numabs=numv*sign;
  	var naint=Math.floor(numabs);
  	var nacent=Math.round((numabs-naint)*100);
  	if (nacent>=100) {nacent=0; naint++;}
  	var nais=''+naint;
  	var nacs=(nacent<10?'0':'')+nacent;
  	if (naint+nacent==0) sign=1;
  	ele.value = (sign==1?'':'-')+nais+'.'+nacs;  
  });
};